package com.example.side_pull_menu.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.SlidingPaneLayout;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;

import com.example.side_pull_menu.R;

import java.util.ArrayList;
import java.util.List;

public class Fragment_7 extends Fragment {
    private TabLayout tabLayout_main;
    private ViewPager viewPager_main;
    private FragmentManager fm;
    private FragmentTransaction ft;
    public Fragment_7() {
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
         View view=inflater.inflate(R.layout.fragment_7, container, false);
        fm=getChildFragmentManager();
         initView(view);
        return view;
    }
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }
    private void initView(View view){
        tabLayout_main = (TabLayout)view.findViewById(R.id.tabLayout_main);
        viewPager_main=(ViewPager)view.findViewById(R.id.viewpager_main);
        List<Fragment>fragmentList=new ArrayList<>();
        fragmentList.add(new Fragment_one());
        fragmentList.add(new Fragment_two());
        fragmentList.add(new Fragment_three());
        String[] stringsTools={"个人信息","充值记录","阈值记录"};
        ViewPagerAdapter adapter=new ViewPagerAdapter(fm,fragmentList,stringsTools);
        viewPager_main.setOffscreenPageLimit(fragmentList.size()-1);
        viewPager_main.setAdapter(adapter);
        tabLayout_main.setTabMode(TabLayout.MODE_FIXED);
        //绑定TabLayout和ViewPager
        tabLayout_main.setupWithViewPager(viewPager_main);
        Log.i("TAG","147"+viewPager_main);
    }
}
